home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of Select: Games Special 4
/
THE BEST OF SELECT Games Special 4 (Select CD-ROM)(1996).iso
/
dosgames
/
abuse
/
lisp
/
ant.lsp
next >
Wrap
Lisp/Scheme
|
1995-09-13
|
17KB
|
619 lines
;; Copyright 1995 Crack dot Com, All Rights reserved
;; See licensing information for more details on usage rights
(setq ant_tints (make-array 11 :initial-contents (list
(def_tint "art/tints/ant/green.spe")
(def_tint "art/tints/ant/blue.spe")
(def_tint "art/tints/ant/brown.spe")
(def_tint "art/tints/ant/egg.spe")
(def_tint "art/tints/ant/yellow.spe")
(def_tint "art/tints/ant/mustard.spe")
(def_tint "art/tints/ant/orange.spe")
(def_tint "art/tints/ant/gray.spe")
normal_tint
normal_tint
normal_tint
)))
/*
------ this code has been compiled --------
(defun no_fall_move (xm ym but)
(move xm ym but))
(if (not (eq (gravity) 0)) ;; if we are in the air don't check for no fall
(move xm ym but)
(let ((oldx (x))
(oldy (y))
(ret (move xm ym but)))
(if (try_move 0 5)
(progn
(set_x oldx)
(set_y oldy)
(set_xacel 0)
(set_state stopped)
(set_xv 0)
(set_gravity 0)
0)
ret))))
(defun will_fall_if_jump ()
nil)
(let ((dist (* (abs (get_ability jump_yvel)) (get_ability jump_xvel)))
(oldx (x))
(oldy (y))
)
(if (> (direction) 0)
(set_x (+ (x) dist))
(set_x (- (x) dist)))
(if (try_move 0 5)
(progn
(set_x oldx)
(set_y oldy)
T)
(progn
(set_x oldx)
(set_y oldy)
nil))))
^^^^^^ this code has been compiled ^^^^^^^^
*/
(defun strait_rocket_ai ()
(set_course (aistate)
(select difficulty
('easy 12)
('medium 15)
('hard 17)
('extreme 22) ))
(set_frame_angle 0 359 (aistate))
(let ((stat (bmove nil)))
(if (eq stat T)
T
(progn
(if (not (eq stat nil))
(progn
(add_object EXPLODE3 (+ (x) (random 5)) (+ (y) (random 5)) 0)
(add_object EXPLODE2 (+ (x) (random 5)) (+ (y) (random 5)) 2)
(add_object EXPLODE3 (- (x) (random 5)) (- (y) (random 5)) 1)
(add_object EXPLODE3 (- (x) (random 5)) (- (y) (random 5)) 2)
(hurt_radius (x) (+ (y) 20) 25 15 nil 10))
(let ((myself (me)))
(with_object (add_object EG_EXPLO (x) (y)) (user_fun myself (car stat)))))
nil))))
(def_char STRAIT_ROCKET
(funs (ai_fun strait_rocket_ai))
(range 10000 10000)
(flags (unlistable T))
(states "art/missle.spe" (stopped (seq "b32r" 1 32))))
(defun animate_ai () (next_picture))
(defun eg_explo_ufun (creator block_flags)
(set_direction (with_object creator (direction)))
(if block_flags
(if (or (blocked_left block_flags) (blocked_right block_flags))
(set_state blocking))))
(def_char EG_EXPLO
(funs (ai_fun animate_ai)
(user_fun eg_explo_ufun))
(range 10000 10000)
(flags (unlistable T))
(states "art/missle.spe"
(stopped (seq "bifl" 1 4))
(blocking (seq "bilw" 1 4))))
/*
------ this code has been compiled --------
(defun alien_wait_time ()
(select difficulty
('easy 6)
('medium 4)
('hard 2)
('extreme 1)))
(defun can_hit_player ()
(let ((firex (+ (x) (* (direction) 15)) )
(firey (- (y) 15))
(playerx (with_object (bg) (x)))
(playery (- (with_object (bg) (y)) 15)))
(can_see firex firey playerx playery nil)))
(defun not_ant_congestion ()
(if (> (direction) 0)
(if (find_object_in_area (+ (x) 23) (- (y) 20) (+ (x) 30) (+ (y) 20) (list ANT_ROOF))
nil
T)
(if (find_object_in_area (- (x) 30) (- (y) 20) (- (x) 23) (+ (y) 20) (list ANT_ROOF))
nil
T)))
(defun roof_above () (not (can_see (x) (y) (x) (- (y) 120) nil)))
(defun fire_at_player ()
(let ((firex (+ (x) (* (direction) 15)) )
(firey (- (y) 15))
(playerx (+ (with_object (bg) (x)) (with_object (bg) (* (xvel) 8))))
(playery (+ (- (with_object (bg) (y)) 15) (with_object (bg) (* (yvel) 2)))))
(if (and (can_see (x) (y) firex firey nil) (can_see firex firey playerx playery nil))
(progn
(let ((angle (atan2 (- firey playery)
(- playerx firex))))
(fire_object (me) (aitype) firex firey angle (bg))
(set_state weapon_fire))
))))
(defun ant_dodge ()
(if (eq need_to_dodge 1)
(progn
(setq need_to_dodge 0)
(if (eq (random 2) 1)
(progn
(set_state stopped)
(go_state 6)) ;; jump at player
(if (roof_above)
(progn
(set_yvel -17) ;; jump up
(set_xvel 0)
(go_state 12))
(progn
(set_yvel -12) ;; long jump
(set_xvel (* (direction) 20))
(set_aistate 6))))
T
nil)))
(defun scream_check ()
(if (can_see (x) (y) (with_object (bg) (x)) (with_object (bg) (y)) nil)
(progn
(if (or (eq no_see_time 0) (> no_see_time 20))
(play_sound ASCREAM_SND 127 (x) (y)))
(setq no_see_time 1))
(setq no_see_time (+ no_see_time 1))))
(defun ant_ai ()
(push_char 30 20)
(if (or (eq (state) flinch_up) (eq (state) flinch_down))
(progn (next_picture) T)
(progn
(select (aistate)
(0 (set_state hanging)
(if (eq hide_flag 0)
(set_aistate 15)
(set_aistate 16)))
(15 ;; hanging on the roof waiting for the main character
(if (next_picture) T (set_state hanging))
(if (if (eq (total_objects) 0);; no sensor, wait for guy
(and (< (distx) 130) (< (y) (with_object (bg) (y))))
(not (eq (with_object (get_object 0) (aistate)) 0)))
(progn
(set_state fall_start) (set_direction (toward))
(set_aistate 1))))
(16 ;; hiding
(set_state hiding)
(if (if (eq (total_objects) 0);; no sensor, wait for guy
(and (< (distx) 130) (< (y) (with_object (bg) (y))))
(not (eq (with_object (get_object 0) (aistate)) 0)))
(progn
(set_state fall_start) (set_direction (toward))
(set_aistate 1))))
(1 ;; falling down
(set_state falling)
(scream_check)
(if (blocked_down (move 0 0 0))
(progn
(set_state landing)
(play_sound ALAND_SND 127 (x) (y))
(set_aistate 9))))
(9 ;; landing / turn around (gerneal finish animation state)
(if (next_picture) T
(if (try_move 0 2)
(progn
(set_gravity 1)
(set_aistate 1))
(progn (set_state stopped)
(go_state 2))))) ;; running
(2 ;; running
(scream_check)
(if (eq (random 20) 0) (setq need_to_dodge 1))
(if (not (ant_dodge))
(if (eq (facing) (toward))
(progn
(next_picture)
(if (and (eq (random 5) 0) (< (distx) 180) (< (disty) 100) (can_hit_player))
(progn
(set_state weapon_fire)
(set_aistate 8)) ;; fire at player
(if (and (< (distx) 100) (> (distx) 10) (eq (random 5) 0))
(set_aistate 4) ;; wait for pounce
(if (and (> (distx) 140)
(not_ant_congestion)
(not (will_fall_if_jump)))
(set_aistate 6)
(if (> (direction) 0)
(if (and (not_ant_congestion) (blocked_right (no_fall_move 1 0 0)))
(set_direction -1))
(if (and (not_ant_congestion) (blocked_left (no_fall_move -1 0 0)))
(set_direction 1)))))))
(progn
(set_direction (toward))
(set_state turn_around)
(set_aistate 9)))))
(4 ;; wait for pounce
(if (ant_dodge) T
(progn
(set_state pounce_wait)
(move 0 0 0)
(if (> (state_time) (alien_wait_time))
(progn
(play_sound ASLASH_SND 127 (x) (y))
(set_state stopped)
(go_state 6))))))
(6 ;; jump
(setq need_to_dodge 0)
(if (blocked_down (move (direction) -1 0))
(progn
(set_aistate 2))))
(8 ;; fire at player
(if (ant_dodge) T
(if (eq (state) fire_wait)
(if (next_picture)
T
(progn
(fire_at_player)
(set_state stopped)
(set_aistate 2)))
(set_state fire_wait))))
(12 ;; jump to roof
(setq need_to_dodge 0)
(set_state jump_up)
(set_yvel (+ (yvel) 1))
(set_xacel 0)
(let ((top (- (y) 31))
(old_yvel (yvel))
(new_top (+ (- (y) 31) (yvel))))
(let ((y2 (car (cdr (see_dist (x) top (x) new_top)))))
(try_move 0 (- y2 top) nil)
(if (not (eq y2 new_top))
(if (> old_yvel 0)
(progn
(set_state stopped)
(set_aistate 2))
(